<?php

/**
 * Description of add
 * 
 * @author 叶风
 * Qq:    355007778
 * Email: ye.fn@163.com
 */

namespace c\log\access;

class add extends \control
{
    var $table = 'log_access';
    var $class = array('PU'=>'\c\auth\permission');
    
    function index_home()
    {
        if (!$this->PU->login(TRUE))
            die;
        
        $d = $_GET;
        $db = $this->db;
        $r = $db->getOne($this->table, 'id, pic', 'url="'. $db->escape($d['url'])  .'" AND title="'. $db->escape($d['h1'])  .'"');
        if ($r)
         {
            $id = $r['id'];
         }
        else{
            $db->save($this->table, array('url'=>$d['url'], 'title'=>$d['h1'], 'pic'=>$d['pic']));
            $id = $db->insert_id();
         }
		 
        $db->save('log_access_time', array('id'=>$id, 'user_id'=>\YF_f::$login_user_id));
        die;
    }
}
